<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>Document</title>
    </head>
    <body>
        <!-- 
            子集问题和组合问题很像，而且更简单，因为它的结果含有[],所以不需要判断终止条件，每次都push到res数组中就行


         -->
        <script>
            var subsets = function (nums) {
                let res = []
                function backTracking(path, startIndex) {
                    res.push([...path])
                    for (let i = startIndex; i < nums.length; i++) {
                        path.push(nums[i])
                        backTracking(path, i + 1)
                        path.pop()
                    }
                }
                backTracking([], 0)
                return res
            }
        </script>
    </body>
</html>
